home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
gui
/
validators.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
4KB
|
103 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import wx
import string
class SimpleValidator(wx.PyValidator):
def __init__(self, char_callbacks, str_callbacks):
if callable(char_callbacks):
char_callbacks = (char_callbacks,)
if callable(str_callbacks):
str_callbacks = (str_callbacks,)
wx.PyValidator.__init__(self)
self.char_callbacks = char_callbacks
self.str_callbacks = str_callbacks
self.Bind(wx.EVT_CHAR, self.OnChar)
self.Bind(wx.EVT_TEXT, self.OnText)
def OnChar(self, event):
key = event.GetKeyCode()
if key < 0 and key > 255 and chr(key) not in string.printable or self.check_char(chr(key)):
event.Skip()
self._last_ok_val = event.EventObject.Value
return None
if not wx.Validator_IsSilent():
wx.Bell()
def OnText(self, event):
s = event.EventObject.Value
if not self.check_string(s):
event.EventObject.Value = self._last_ok_val
else:
self._last_ok_val = s
event.Skip()
def check_char(self, c):
return (all,)((lambda .0: for cb in .0:
cb(c))(self.char_callbacks))
def check_string(self, s):
return (all,)((lambda .0: for cb in .0:
cb(s))(self.str_callbacks))
def Clone(self):
return SimpleValidator(self.char_callbacks, self.str_callbacks)
def Validate(self, win):
return 1
def TransferToWindow(self):
return True
def TransferFromWindow(self):
return True
def __add__(self, other):
return SimpleValidator(self.char_callbacks + other.char_callbacks, self.str_callbacks + other.str_callbacks)
def string_check(type):
valid = getattr(string, type)
return (lambda s: (all,)((lambda .0: for c in .0:
c in valid)(s))
)
def AlphaOnly():
return SimpleValidator((string_check('letters'),), ())
def DigitsOnly():
return SimpleValidator((string_check('digits'),), ())
def LengthLimit(n):
return SimpleValidator(((),), ((lambda s: len(s) <= n),))
def NumericLimit(start, stop = None):
if stop is None:
start = 0
stop = start
return None + DigitsOnly()((SimpleValidator, ()), (lambda s: if not not s:
passNone if int(s) <= int(s) else int(s) <= stop))
common_validators = dict(d = DigitsOnly, s = AlphaOnly)